﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/MasterPage.Master" AutoEventWireup="true" CodeBehind="DMNguoiDung_View.aspx.cs" Inherits="QLKS.Views.DMNguoiDung_View" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="title-right"><span></span>Danh Muc Người Dùng</div>
    <ul class="button">
        <li><asp:LinkButton style="background: url('/Content/themes/add_bt.png') no-repeat 5px #E0DEDE; " ID="btnNew" runat="server" onclick="btnNew_Click"><span></span>Thêm</asp:LinkButton></li>
        <li><asp:LinkButton style="background: url('/Content/themes/del_bt.png') no-repeat 5px #E0DEDE; " ID="btnDelete" runat="server" onclick="btnDelete_Click" OnClientClick="return confirm('Bạn có thực sư muốn xóa dữ liệu này??');"><span></span>Xóa</asp:LinkButton></li>
        <li><asp:LinkButton style="background: url('/Content/themes/fitx_bt.png') no-repeat 5px #E0DEDE; " ID="btnEdit" runat="server" onclick="btnEdit_Click"><span></span>Sửa</asp:LinkButton></li>
        <li><asp:LinkButton style="background: url('/Content/themes/sav_bt.png') no-repeat 5px #E0DEDE; " ID="btnSave" runat="server" onclick="btnSave_Click" OnClientClick="return checkInput();" ><span></span>Lưu</asp:LinkButton></li>
        <li><asp:LinkButton style="background: url('/Content/themes/can_bt.png') no-repeat 5px #E0DEDE; " ID="btnCancel" runat="server" onclick="btnCancel_Click"><span></span>Hủy</asp:LinkButton></li>
    </ul>
    <asp:Panel ID="pnlMain" runat="server" CssClass="swap-product">
        <asp:GridView ID="gvMain" runat="server" AutoGenerateColumns="False" GridLines="None" 
            AllowPaging="True"  AllowSorting="True" CssClass="list-grid" ShowHeaderWhenEmpty="true"
            onpageindexchanging="gvMain_PageIndexChanging" onrowdatabound="gvMain_RowDataBound" onsorting="gvMain_Sorting" >
            <Columns>
                <asp:TemplateField>
                    <HeaderStyle Width="20px"/>
					<ItemStyle Width="20px"/>
					<HeaderTemplate>
						<asp:CheckBox ID="chkall" Runat="server" TextAlign="Left" />
					</HeaderTemplate>
					<ItemTemplate>
						<asp:CheckBox ID="chkid" Runat="server" TextAlign="Left" />
					</ItemTemplate>
					<HeaderStyle HorizontalAlign="Left" />
				</asp:TemplateField>
				<asp:TemplateField HeaderText="STT">
					<ItemStyle Width="20px" />
					<HeaderStyle Width="20px"/>
					<ItemTemplate>
						<%# Container.DataItemIndex + 1 %>
					</ItemTemplate>
				</asp:TemplateField>
				<asp:TemplateField Visible="false">
					<ItemTemplate>
						<asp:Label ID="lblID" runat="server" Text='<%#Bind("MaNguoiDung") %>'></asp:Label>
					</ItemTemplate>
				</asp:TemplateField>
				<asp:BoundField DataField="TenNguoiDung" HeaderText="Tên đăng nhập" SortExpression="TenNguoiDung" >
					<ItemStyle Width = "100" CssClass="name" />
				</asp:BoundField>
                <asp:BoundField DataField="HoTen" HeaderText="Họ và tên" SortExpression="HoTen" >
					<ItemStyle Width = "150" CssClass="name" />
				</asp:BoundField>
				<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" >
					<ItemStyle Width = "100" />
				</asp:BoundField>
                <asp:BoundField DataField="DienThoai" HeaderText="Điện thoại">
					<ItemStyle Width = "100" />
				</asp:BoundField>
                <asp:BoundField DataField="DiaChi" HeaderText="Địa chỉ">
					<ItemStyle Width = "150" />
				</asp:BoundField>
                <asp:BoundField DataField="GhiChu" HeaderText="Ghi chú" >
				</asp:BoundField>
            </Columns>
        </asp:GridView>
    </asp:Panel>
    <asp:Panel ID="pnlUpdate" runat="server" CssClass="swap-product" Visible="false" >
        <table style="width:100%" border="0" class="list-update">
            <tr>
				<td style="width:20%;" align="right">Tên đăng nhập:</td>
				<td>
					<asp:TextBox ID="txtTenNguoiDung" runat="server" MaxLength="100" CssClass="textbox required" Width="300px"></asp:TextBox>
				</td>
			</tr>
            <tr>
				<td style="width:20%;" align="right">Mât khẩu:</td>
				<td>
					<asp:TextBox ID="txtMatKhau" runat="server" MaxLength="50" CssClass="textbox required" TextMode="Password" Width="300px"></asp:TextBox>
				</td>
			</tr>
            <tr>
				<td style="width:20%;" align="right">Xác nhận mât khẩu:</td>
				<td>
					<asp:TextBox ID="txtXacNhanMatKhau" runat="server" MaxLength="50" CssClass="textbox required" TextMode="Password" Width="300px"></asp:TextBox>
				</td>
			</tr>
            <tr>
				<td style="width:20%;" align="right">Họ và tên:</td>
				<td>
					<asp:TextBox ID="txtHoTen" runat="server" MaxLength="100" CssClass="textbox required" Width="300px"></asp:TextBox>
				</td>
			</tr>
            <tr>
				<td style="width:20%;" align="right">Email:</td>
				<td>
					<asp:TextBox ID="txtEmail" runat="server" MaxLength="50" CssClass="textbox required" Width="300px"></asp:TextBox>
				</td>
			</tr>
            <tr>
				<td style="width:20%;" align="right">Điện thoại:</td>
				<td>
					<asp:TextBox ID="txtDienThoai" runat="server" MaxLength="50" CssClass="textbox required" Width="300px"></asp:TextBox>
				</td>
			</tr>
            <tr>
				<td style="width:20%;" align="right">Địa chỉ:</td>
				<td>
					<asp:TextBox ID="txtDiaChi" runat="server" MaxLength="100" CssClass="textbox" Width="300px"></asp:TextBox>
				</td>
			</tr>
            <tr>
				<td style="width:20%;" align="right">Ghi chú:</td>
				<td>
					<asp:TextBox ID="txtGhiChu" runat="server" MaxLength="500" TextMode="MultiLine" Rows="5" CssClass="textbox" Width="300px"></asp:TextBox>
				</td>
			</tr>
        </table>
    </asp:Panel>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#<%=txtTenNguoiDung.ClientID %>").change(function () {
                var ctrl = $(this);
                if ($.trim(ctrl.val()) == '') {
                    ctrl.css({ "border": "1px solid red", "background": "#FFCECE" });
                } else {
                    checkExistsUser(ctrl.val(),
                    function (data) {
                        if (data.result == 1) {
                            alert('Tên người dùng đã tồn tại.');
                            ctrl.css({ "border": "1px solid red", "background": "#FFCECE" });
                            ctrl.focus();
                        } else {
                            ctrl.css({ "border": "", "background": "" });
                        }
                    }, null);
                }
            });
        });
        function checkInput() {
            var isValid = true;
            $('.list-update input.required').each(function () {
                if ($.trim($(this).val()) == '') {
                    isValid = false;
                    $(this).css({ "border": "1px solid red", "background": "#FFCECE" });
                }
                else {
                    $(this).css({ "border": "", "background": "" });
                }
            });
            if (isValid) {
                //check pass
                var pass = $("#<%=txtMatKhau.ClientID %>").val();
                var confirmPass = $("#<%=txtXacNhanMatKhau.ClientID %>").val();
                if (pass != confirmPass) {
                    alert('Vui lòng nhập lại mật khẩu.');
                    $("#<%=txtXacNhanMatKhau.ClientID %>").css({ "border": "1px solid red", "background": "#FFCECE" });
                    $("#<%=txtXacNhanMatKhau.ClientID %>").focus();
                    return false;
                }
                //kiem tra email
                var sEmail = $("#<%=txtEmail.ClientID %>").val();
                if ($.trim(sEmail).length == 0) {
                    alert('Vui lòng nhập địa chỉ email hợp lệ.');
                    $("#<%=txtEmail.ClientID %>").css({ "border": "1px solid red", "background": "#FFCECE" });
                    return false;
                }
                else if (validateEmail(sEmail)) {
                    $("#<%=txtEmail.ClientID %>").css({ "border": "", "background": "" });
                    isValid = true;
                }
                else {
                    alert('Email không hợp lệ.');
                    $("#<%=txtEmail.ClientID %>").css({ "border": "1px solid red", "background": "#FFCECE" });
                    return false;
                }
            }
            return isValid;
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" runat="server" contentplaceholderid="Menu">
<dl>
                            <dt ><a href="#">QUẢN LÝ PHÒNG</a></dt>
                            
                            <dd style="display: none;">
                                <ul>
                                    <li ><a href="Index.aspx">Tổng quan</a></li>
                                    <li ><a href="PhieuThuePhong_View.aspx">Phiếu thuê phòng</a></li>
                                    <li><a href="PhieuTraPhong_View.aspx">Phiếu trả phòng</a></li>
                                    <li><a href="HoaDon_View.aspx">Hóa đơn</a></li>
                                </ul>
                            </dd>
                            <dt class="currentac" ><a class="" href="#">HỆ THỐNG</a></dt>
                            <dd  class="currentac" style="display: block;">
                                <ul>
                                    <li><a href="DMPhong_View.aspx">Danh mục phòng</a></li>
                                    <li><a href="DMKhachHang_View.aspx">Danh mục khách hàng</a></li>
                                    <li><a href="DMLoaiPhong_View.aspx">Danh mục loại phòng</a></li>
                                    <li><a href="DMLoaiKhachHang_View.aspx">Danh mục loại khách hàng</a></li>
                                    <li class="currentac"><a href="DMNguoiDung_View.aspx">Danh mục người dùng</a></li>
                                    <li ><a href="ThamSoHeThong_View.aspx">Tham số hệ thống</a></li>
              
                                </ul>
                            </dd>
                            <dt class=""><a href="#">BÁO CÁO</a></dt>
                            <dd  style="display: none;">
                                <ul>
                                    <li><a href="BaoCaoDoanhThuTheoLoaiPhong_View.aspx">Doanh thu theo loại phòng</a></li>
                                    <li><a href="BaoCaoMatDoSuDungPhong_View.aspx">Mật độ sử dụng phòng</a></li>
                
                                </ul>
                            </dd>
                            
                        </dl>
</asp:Content>